package com.demo.api.controller;

import com.demo.api.conf.ResultT;
import com.demo.api.model.po.UserPo;
import com.demo.api.repository.RedisCacheRepository;
import com.demo.api.repository.UserRepository;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author: cja
 * @date: 2019/11/13 19:42
 */
@RestController
@RequestMapping(value = "/user")
@Api(description = "")
@Slf4j
public class UserController {

    @Resource
    private RedisCacheRepository cacheRepository;

    @ApiOperation(value = "测试")
    @GetMapping(value = "/test")
    @ResponseBody
    public ResultT<String> test() {
        return new ResultT<>("hello spring. . . ");
    }

    @Autowired
    private UserRepository userRepository;

    @GetMapping(value = "/list")
    @ResponseBody
    public ResultT<List<UserPo>> list() {
        return new ResultT<List<UserPo>>(userRepository.findAll());
    }
}
